# Build recipe for password-store
#
# Copyright 2016, 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
#
# This recipe is free software, under the terms of the Apache License 2.0

program=password-store
version=1.7.1
release=1

description="
Password management should be simple and follow Unix philosophy. With
pass, each password lives inside of a gpg encrypted file whose
filename is the title of the website or resource that requires the
password. These encrypted files may be organized into meaningful
folder hierarchies, copied from computer to computer, and, in general,
manipulated using standard command line file management utilities.

pass makes managing these individual password files extremely
easy. All passwords live in ~/.password-store, and pass provides some
nice commands for adding, editing, generating, and retrieving
passwords. It is a very short and simple shell script. It's capable of
temporarily putting passwords on your clipboard and tracking password
changes using git.

You can edit the password store using ordinary unix shell commands
alongside the pass command. There are no funky file formats or new
paradigms to learn. There is bash completion so that you can simply
hit tab to fill in names and commands, as well as completion for zsh
and fish available in the completion folder.
"

homepage=https://www.passwordstore.org/
license=GPLv2+

tarname=${program}-${version}.tar.xz

# Remote source(s)
fetch=https://git.zx2c4.com/password-store/snapshot/$tarname

# Source documentation
docs="COPYING README"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs ; do
            cp -p $file "${destdir}${docsdir}"
	        done
}
